package com.ailot.cloud.upms.api.mapper;

import com.ailot.cloud.upms.common.entity.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author litao
 */
public interface SysMenuMapper extends BaseMapper<SysMenu> {


    @Select("SELECT sys_menu.* FROM sys_menu " +
            "LEFT JOIN sys_role_menu ON sys_menu.id = sys_role_menu.menu_id " +
            "WHERE sys_menu.del_flag = 1 AND sys_role_menu.role_id = #{roleId} " +
            "ORDER BY sys_menu.sort DESC")
    @Results({
            @Result(column = "parent_id", property = "parentId"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "del_flag", property = "delFlag"),
    })
    List<SysMenu> getMenusByRoleId(String roleId);

}
